Release 10.1A: OpenEdge Development:
ProDataSets
ProDataSets and temp-tables
The Progress temp-table already provides a large measure of support for managing sets of data independent of the database. Because the ProDataSet is in many ways an extension of that support, it’s worth briefly reviewing some of the temp-table characteristics that are also part of the ProDataSet.
Temp-tables compared to database tables
A temp-table allows you to define a table that is not part of any persistent database. You can use temp-tables within a session or pass them between sessions. Temp-tables provide in-memory buffering of data and transparent overflow to a temporary database on disk when necessary. You can define a temp-table as being
LIKEa database table, and you can add fields of any type to this definition, or you can define the table as a set of fields independent of any particular database table. You can create, read, update, and delete records in the temp-table much as you can with records in a database table. You can define indexes to manage large sets of data efficiently. You can access the records in the table withFINDandFOREACHlogic or with queries.Static or dynamic temp-tables
You can define a temp-table in a static definition, specifying all its fields and indexes in a single statement. You can also create a temp-table as a dynamic object with a handle and then add fields, buffers, and indexes to it in individual successive statements, finalizing the temp-table structure with a
TEMP-TABLE-PREPAREmethod. You can also retrieve the handle to a static temp-table and then access its attributes, the same as you can a dynamic temp-table, in order to see what fields and indexes it contains, what its default buffer is, and so forth.Passing temp-tables
You can pass a temp-table between procedures within a session or between sessions, such as between a server session that loads database data into the table and a client session that views the data and perhaps allows changes. You can pass a temp-table as a static parameter and receive it as a static or dynamic object. You can also pass a dynamic temp-table and receive it as either a static or dynamic object.
In all these cases, the names of the tables and fields do not need to match on the two sides of the call. Only the essentials of the field definitions—their number, sequence, and data types—need to match. Field names along with the format and other attributes can be different, as can index definitions, because indexes are rebuilt as the temp-table is received.
In addition, you can pass a temp-table by
HANDLE, in which case only the handle as a pointer to either a static or dynamic temp-table is passed. Nothing is copied from caller to callee. Because handles are not valid between sessions, and because there is no way to share either the definition or data across sessions without copying it, theHANDLEform can be used only between procedures in the same session.ProDataSet comparison
A ProDataSet is constructed from multiple temp-tables and shares and extends all of these temp-table characteristics:
- The temp-table definitions that make up the ProDataSet allow developers to define, in a standard way, a level of indirection between the actual data configuration in a database, or other data source, and the data definition that the application uses. These table definitions can mask joins between tables in order to simplify data representation. They can rename fields to match names used in business logic or to standardize naming. They can combine data from one or more databases with data from other data sources. They can mask changes to the underlying data structure, for example, as database design work is done to gradually clean up a complex and inconsistent older design. Temp-tables allow all these things today, but the ProDataSet makes it more straightforward for developers to standardize their design on this view of data.
- Developers can define ProDataSets statically or dynamically. The ProDataSet, whether static or dynamic, has a single handle that you can use to access its methods and attributes and pass the entire ProDataSet as a single parameter to a procedure within the same session, in another Progress session, or to an application running on an entirely different platform such as Microsoft .NET.
- The ProDataSet supports the parameter forms
HANDLE,DATASET, andDATASET-HANDLE.LiketheTABLEparameter form for an individual temp-table, theDATASETform passes the ProDataSet as a static parameter. Similarly, theDATASET-HANDLEform is likeTABLE-HANDLEin that it passes a dynamic reference to the ProDataSet. When the procedure call is within a session, the ProDataSet is normally passed by reference for maximum efficiency. When the call is remote, the entire definition of the ProDataSet, with its temp-table buffers, relationships between buffers, and so on, is marshaled along with the data just as is done for temp-tables today.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |